package com.javacv.plus.extensions.video.steps;

import com.javacv.plus.core.processor.ProcessorContext;
import com.javacv.plus.core.processor.ProcessorStep;
import com.javacv.plus.extensions.video.VideoProcessor;
import com.javacv.plus.extensions.video.VideoResult;
import lombok.extern.slf4j.Slf4j;

/**
 * 视频滤镜处理步骤
 */
@Slf4j
public class VideoFilterStep implements ProcessorStep<VideoProcessor, VideoResult> {

    /**
     * 滤镜类型枚举
     */
    public enum FilterType {
        BRIGHTNESS("亮度调整"),
        CONTRAST("对比度调整"),
        SATURATION("饱和度调整"),
        BLUR("模糊效果"),
        SHARPEN("锐化效果"),
        GRAYSCALE("灰度转换");

        private final String description;

        FilterType(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    private final FilterType filterType;
    private final double intensity;

    public VideoFilterStep(FilterType filterType, double intensity) {
        this.filterType = filterType;
        this.intensity = intensity;
    }

    @Override
    public VideoResult execute(VideoProcessor processor, ProcessorContext context) throws Exception {
        log.info("应用视频滤镜: {} (强度: {})", filterType.getDescription(), intensity);

        // 这里应该实现具体的滤镜逻辑
        // 由于FFmpeg集成较为复杂，这里只是记录操作
        context.setAttribute("filter_" + filterType.name(), intensity);

        log.info("视频滤镜 {} 应用完成", filterType.getDescription());
        return null; // 中间步骤不返回结果
    }

    @Override
    public String getStepName() {
        return "VideoFilter_" + filterType.name();
    }

    @Override
    public int getPriority() {
        return 50; // 中等优先级
    }
} 